package com.margo.project.web.mvcconfig.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.margo.project.web.mvcconfig.model.MargoBodyAdviceVO;
import com.margo.project.web.mvcconfig.requestbodyadvice.DataLicense;
import com.margo.project.web.mvcconfig.requestbodyadvice.ParamJsonDeserializer;
import com.margo.project.web.utils.ResultUtils;
import com.margo.project.web.utils.ResultVO;

@Controller
@RequestMapping("/mvcconfig")
public class MargoRequestBodyAdviceController {
	
	private Logger logger=LoggerFactory.getLogger(this.getClass());
	
	@ResponseBody
	@PostMapping("/advice")
	public ResultVO advice(@RequestBody @ParamJsonDeserializer(fieldName="workStatus",length=3) MargoBodyAdviceVO margoBodyAdviceVO) {
		logger.info(margoBodyAdviceVO.toString());
		return ResultUtils.success(1);
	}
	
	@ResponseBody
	@PostMapping("/dataLicense")
	public ResultVO dataLicense(@RequestBody @ParamJsonDeserializer(fieldName="workStatus",length=3) @DataLicense(parkTableName="workA") MargoBodyAdviceVO margoBodyAdviceVO) {
		logger.info(margoBodyAdviceVO.toString());
		return ResultUtils.success(1);
	}
}
